package com.hundsun.fcp.activity;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.hundsun.fcp.R;
import com.hundsun.fcp.base.BaseActivity;
import com.hundsun.fcp.common.Redirect;
import com.hundsun.fcp.common.utils.StringUtils;
import com.hundsun.fcp.dao.MineDao;
import com.hundsun.fcp.manager.FcpUserManager;
import com.hundsun.fcp.openapi.trade.bean.ResponseLoginBean;
import com.hundsun.fcp.widget.HeaderMenu;

public class MineAccountInfoActivity extends BaseActivity implements OnClickListener{
	//头像
	private View mPhoto;
	private ImageView photo;
	//昵称
	private View mNickname;
	private TextView nickname;
	//姓名
	private View mName;
	private TextView name;
	//绑定手机
	private View mBindingMobile;
	private TextView bindingMobile; 
	//身份认证
	private View mIdAuth;
	private TextView isAuth;
	
	private String clientno ;
	private MineDao mineDao ;
	private ResponseLoginBean mBean ;
	@Override
	protected int getContentLayout() {
		return R.layout.fcp_mine_account_info;
	}
	@Override
	protected void initHeader() {
		super.initHeader();
		mHeaderMenu.setTitle(R.string.mine_head_accInfo);
	}
	
	@Override
	public void initView() {
		super.initView();
		clientno = FcpUserManager.getInstance().getUserClientNo() ;
		mineDao = new MineDao(this) ;
		mPhoto = findViewById(R.id.rl_accinfo_head);
		photo = (ImageView) findViewById(R.id.user_photo);
		mNickname = findViewById(R.id.rl_accinfo_nickname);
		nickname = (TextView) findViewById(R.id.tv_nickname);
		mName = findViewById(R.id.rl_accinfo_name);
		name = (TextView) findViewById(R.id.tv_name);
		mBindingMobile = findViewById(R.id.rl_accinfo_mobile);
		bindingMobile = (TextView) findViewById(R.id.tv_mobile);
		mIdAuth = findViewById(R.id.rl_accinfo_id_auth);
		isAuth = (TextView) findViewById(R.id.tv_isAuth);
		
		mPhoto.setOnClickListener(this);
		mNickname.setOnClickListener(this);
		mName.setOnClickListener(this);
		mBindingMobile.setOnClickListener(this);
		mIdAuth.setOnClickListener(this);
		
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		initvalue() ;
	}
	
	void initvalue() {
		mBean = mineDao.queryMineResult(clientno) ;
		nickname.setText(mBean.shortname) ;
		bindingMobile.setText(StringUtils.showMobileCiphertext(mBean.mobile)) ;
	} ;

	@Override
	public void onClick(View v) {
		if(v == mPhoto){
			
		}else if(v == mNickname){
			Redirect.startModifyNickname(this,nickname.getText().toString());
		}else if(v == mBindingMobile){
			Redirect.startBindingMobile(this);
		}else if(v == mIdAuth){
			Redirect.startIdAuth(this);
		}
	}
}
